﻿package net.wangit.view.enumeration;

import net.wangit.MapList;
import net.wangit.util.Checker;

public class EnumerationConfig {

	private String domain;
	private String id;
	private int dataMode;
	private String datasource;
	private String dataExpression;
	private boolean cacheEnabled;
	private boolean hasDataPrivilege;
	private MapList list;

	public EnumerationConfig(String domain, String id) {
		this.domain = domain;
		this.id = id;
	}

	public boolean isCacheEnabled() {
		return cacheEnabled;
	}

	protected void setCacheEnabled(boolean cacheEnabled) {
		this.cacheEnabled = cacheEnabled;
	}

	public MapList getList() {
		return list;
	}

	protected void setList(MapList items) {
		list = items;
	}

	public String getDatasource() {
		return datasource;
	}

	protected void setDatasource(String datasource) {
		this.datasource = datasource;
	}

	public String getDomain() {
		return domain;
	}

	public String getId() {
		return id;
	}

	public boolean hasDataPrivilege() {
		return hasDataPrivilege;
	}

	protected void setHasDataPrivilege(boolean hasDataPrivilege) {
		this.hasDataPrivilege = hasDataPrivilege;
	}

	public String getDataExpression() {
		return dataExpression;
	}

	protected void setDataExpression(String dataExpression) {
		if (Checker.isEmpty(dataExpression)) {
			this.dataExpression = dataExpression;
		} else {
			dataExpression = dataExpression.replaceAll("\r\n", " ");
			dataExpression = dataExpression.replaceAll("\r", " ");
			this.dataExpression = dataExpression.replaceAll("\n", " ");
		}
	}

	public int getDataMode() {
		return dataMode;
	}

	protected void setDataMode(int dataMode) {
		this.dataMode = dataMode;
	}
}
